{extend name="$lake_admin_layout"/}

{block name="main"}
<div class="layui-card">
    <div class="layui-card-header layui-bg-cyan">栏目设置</div>
    <div class="layui-card-body">
        <form class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    封面
                </label>
                <div class="layui-input-block w500">
                    <div class="js-upload-image">
                        <div id="file_list_cover" 
                            class="uploader-cover">
                            {notempty name="$info.cover"}
                            <div class="file-item thumbnail">
                                <img data-original="{$info.cover|lake_get_file_path|default='admin/admin/img/none.png'}" 
                                    src="{$info.cover|lake_get_file_path|default='admin/admin/img/none.png'}" 
                                    width="100" 
                                    style="max-height: 100px;">
                                <i class="iconfont icon-delete_fill remove-picture" 
                                    data-id="{$info.cover}"></i>
                            </div>
                            {/notempty}
                        </div>
                        <input type="hidden" 
                            name="cover" 
                            data-multiple="false" 
                            data-watermark='' 
                            data-thumb='' 
                            data-size="{:config('app.upload_image_size')}" 
                            data-ext="{:config('app.upload_image_ext')}" 
                            id="cover" 
                            value="{$info.cover|default=''}">
                        <div class="layui-clear"></div>
                        <div id="picker_cover">
                            <i class="layui-icon layui-icon-upload"></i> 
                            上传单张图片
                        </div>
                    </div>
                </div>
            </div>
            
            {if $info['type'] == 1}
            <div class="layui-form-item">
                <label class="layui-form-label">
                    列表模版
                </label>
                <div class="layui-input-block">
                    <div class="layui-input-inline w300">
                        <input type="text" name="template_list" autocomplete="off" placeholder="列表模版" class="layui-input" value="{$info.template_list}" id="template_list">
                    </div>
                    
                    <div class="layui-input-inline">
                        <select lay-filter="template_list">
                            <option data-define=""></option>
                            {volist name="template.lists" id="vo"}
                                <option data-define="{$vo}" >{$vo}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-input-block w300">
                    <div class="layui-form-mid layui-word-aux">设置栏目的列表模版</div>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">
                    详情模版
                </label>
                <div class="layui-input-block">
                    <div class="layui-input-inline w300">
                        <input type="text" name="template_detail" autocomplete="off" placeholder="详情模版" class="layui-input" value="{$info.template_detail}" id="template_detail">
                    </div>
                    
                    <div class="layui-input-inline">
                        <select lay-filter="template_detail">
                            <option data-define=""></option>
                            {volist name="template.details" id="vo"}
                                <option data-define="{$vo}" >{$vo}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-input-block w300">
                    <div class="layui-form-mid layui-word-aux">设置栏目的详情模版</div>
                </div>
            </div>
            {/if}
            
            {if $info['type'] == 2}
            <div class="layui-form-item">
                <label class="layui-form-label">
                    单页模版
                </label>
                <div class="layui-input-block">
                    <div class="layui-input-inline w300">
                        <input type="text" name="template_page" autocomplete="off" placeholder="单页模版" class="layui-input" value="{$info.template_page}" id="template_page">
                    </div>
                    
                    <div class="layui-input-inline">
                        <select lay-filter="template_page">
                            <option data-define=""></option>
                            {volist name="template.pages" id="vo"}
                                <option data-define="{$vo}" >{$vo}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-input-block w300">
                    <div class="layui-form-mid layui-word-aux">设置栏目的单页模版</div>
                </div>
            </div>
            {/if}
            
            <div class="layui-form-item">
                <label class="layui-form-label">
                    列表地址
                </label>
                <div class="layui-input-block w500">
                    <input type="text" name="index_url" value="{$info.index_url}" autocomplete="off" placeholder="列表地址" class="layui-input">
                </div>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">
                        填写字母、数字、下划线及其组合，为空不重写
                    </div>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">
                    内容地址
                </label>
                <div class="layui-input-block w500">
                    <input type="text" name="content_url" value="{$info.content_url}" autocomplete="off" placeholder="内容地址" class="layui-input">
                </div>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">
                        填写字母、数字、下划线及其组合，为空不重写
                    </div>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">
                    排序字段
                </label>
                <div class="layui-input-block w500">
                    <input type="text" name="order_list" value="{$info.order_list}" autocomplete="off" placeholder="排序字段" class="layui-input">
                </div>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">
                        半角逗号分割
                    </div>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">列表定义</label>
                <div class="layui-input-block w500">
                    <textarea name="list_grid" placeholder="字段:字段显示中文名" class="layui-textarea">{$info.list_grid}</textarea>
                </div>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">
                        在栏目列表表头会显示的字段，以回车分割
                    </div>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">每页数量</label>
                <div class="layui-input-block w500">
                    <input type="text" name="pagesize" value="{$info.pagesize}" autocomplete="off" placeholder="链接排序" class="layui-input">
                </div>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">
                        该设置影响后台列表及默认前台列表显示
                    </div>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">包含子级</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_inchildren" value="1" title="包含" {if $info.is_inchildren==1}checked{/if}>
                    <input type="radio" name="is_inchildren" value="0" title="禁止" {if $info.is_inchildren==0}checked{/if}>
                </div>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">
                        是否在列表显示时包含子级的数据
                    </div>
                </div>
            </div>
            
            <input type="hidden" value="{$info.id}" name="id" />
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="script"}
<script type="text/javascript" src="admin/libs/webuploader/webuploader.min.js"></script>
<link rel="stylesheet" href="admin/libs/webuploader/webuploader.css">
<script type="text/javascript" src="admin/admin/js/form.js"></script>
<script type="text/javascript" src="admin/libs/viewer/viewer.min.js"></script>
<link rel="stylesheet" href="admin/libs/viewer/viewer.min.css">

<script type="text/javascript">
$('.uploader-cover').viewer();
    
layui.use(['layer', 'form'], function() {
    var iconPicker = layui.iconPicker,
        form = layui.form,
        layer = layui.layer,
        $ = layui.$;
    
    var template_list = $('#template_list').val();
    $("[lay-filter='template_list'] option[data-define='"+template_list+"']").attr("selected", true);
    var template_detail = $('#template_detail').val();
    $("[lay-filter='template_detail'] option[data-define='"+template_detail+"']").attr("selected", true);
    var template_page = $('#template_page').val();
    $("[lay-filter='template_page'] option[data-define='"+template_page+"']").attr("selected", true);
    form.render('select');

    form.on('select(template_list)', function(data) {
        $('#template_list').val($(data.elem).find("option:selected").attr("data-define"));
    });
    form.on('select(template_detail)', function(data) {
        $('#template_detail').val($(data.elem).find("option:selected").attr("data-define"));
    });
    form.on('select(template_page)', function(data) {
        $('#template_page').val($(data.elem).find("option:selected").attr("data-define"));
    });
});
</script>
{/block}